package com.monika.main.system.util;

import com.monika.main.system.log.entity.OperateLog;
import org.springframework.core.NamedThreadLocal;

/**
 * Author whh
 * Date 2023/04/16/ 0:50
 * <p></p>
 */
public class ThreadLocalContextHolder {



    private static final ThreadLocal<OperateLog> OPERATE_LOG_THREAD_LOCAL = new NamedThreadLocal<>("OPERATE_LOG_THREAD_LOCAL");


    /**
     * 获取OperateLog
     * @return
     */
    public static OperateLog getOperateLog(){
        return OPERATE_LOG_THREAD_LOCAL.get();
    }


    /**
     * 设置OperateLog
     * @param operateLog
     */
    public static void setOperateLog(OperateLog operateLog){
         OPERATE_LOG_THREAD_LOCAL.set(operateLog);
    }

    /**
     *清理OPERATE_LOG_THREAD_LOCAL
     */
    public static void clearOperateLogThreadLocal(){
        OPERATE_LOG_THREAD_LOCAL.remove();
    }


}
